import {Container} from './VCL/Container';
import {LoadMask} from './VCL/LoadMask';
import {Cookie} from './Cookie';

var Al = window.Al || (window.Al = {});
Al.LoadMask = new LoadMask;
Al.Cookie = new Cookie;
$(() => {
  var link = $('link[href^="/theme"]'), style;
  Al.changeTheme = (path) => {
    Al.LoadMask.show();
    $.get(path, (r) => {
      if (link) {
        link.remove();
        link = null;
        style = $('<style>').appendTo('head');
      }
      style.text(r);
      Al.Cookie.set('current_theme', path.match(/^\/theme\/(\w+)?\.css/)[1]);
      Al.LoadMask.hide();
    });
  };
  $('a[href="#"]').click((e) => { e.preventDefault() });
});

window.cont = new Container({tpl: '<div>sdlfjkbasdlajsdb</div>'});
$(() => cont.show());